<!DOCTYPE html>
<html lang="en">
<head>
<title>新增部门页面</title> 
#@common()
<style type="text/css">
body { padding: 10px; background: #fff; }
.layui-form-label { min-width: 200px; }
body * {color: #393939 !important;}
</style>
</head>
<body>
	<form class="layui-form layui-fluid" action="">
		<input type="hidden" name="org.id" value="#(org.id)" />
		<input type="hidden" name="org.parentid" value="#if(parent??)#(parent.id)#else 0#end" />
		<div class="layui-row">
			<div class="layui-form-item">
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-form-label">上级部门</div>
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6">
					<input autocomplete="off" class="layui-input" type="text" disabled value="#if(parent??)#(parent.name)#else无#end">
				</div>
			</div>
			
			<div class="layui-form-item">
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-form-label">部门名称</div>
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6">
					<input autocomplete="off" type="text" name="org.name" 
						required lay-verify="required" placeholder="请输入部门名称" class="layui-input"
						value="#(org.name)">
				</div>
			</div>
			
			<div class="layui-form-item">
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-form-label">部门编号</div>
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6">
					<input autocomplete="off" type="text" name="org.code" 
						required lay-verify="required" placeholder="请输入部门编号" class="layui-input"
						value="#(org.code)">
				</div>
			</div>
			
			<div class="layui-form-item layui-form-text">
	    		<label class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-form-label">部门备注</label>
	    		<div class="layui-col-md6 layui-col-xs6 layui-col-sm6" >
	     		 	<textarea name="org.remark" placeholder="请输入部门备注" class="layui-textarea" style="height: 150px;">#(org.remark)</textarea>
	    		</div>
	  		</div>
	  		
	  		<div class="layui-form-item">
				<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-col-md-offset6 layui-col-xs-offset6 layui-col-sm-offset6">
					<button class="layui-btn layui-bg-blue" lay-submit lay-filter="form">保存数据</button>
					<button type="button" class="layui-btn layui-btn-primary" onclick="closeLayer()">关闭返回</button>
				</div>
			</div>
		</div>
	</form>

	<script>
		//layui的相关数据加载
		layui.use('form', function() {
			var form = layui.form;
			//监听提交
			form.on('submit(form)', function(data) {
				Http.post('admin/org/save', data.field, function(res){
					if(res.state == 'ok'){
						parent.layer.msg('保存成功',{shade:0.1})
						closeLayer();
					} else {
						parent.layer.msg('保存失败')
					}
				})
				return false;
			});
		});
		
		/** 关闭系统菜单录入页面 */
		function closeLayer(){
			parent.jqGrid.reload();
			closeParentLayer();
		}
		
	</script>
</body>
</html>